﻿using System;
using System.Collections.Generic;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using Moq;
using System.Diagnostics;

namespace Opo.Perspective.Core.PipelinePlugins
{
    [TestFixture]
    public class TagSpamPluginTests
    {
        Mock<Message> _mailMessage;

        [TestFixtureSetUp]
        public void Setup()
        {
            _mailMessage = new Mock<Message>();
            _mailMessage.Object.Headers.Add("X-Spam-Status", "Yes, 4.8");
            _mailMessage.Object.Headers.Add("X-GMX-Antispam", "5");
        }

        [TestFixtureTearDown]
        public void Teardown()
        {

        }

        [Test]
        public void AddsSpamTag()
        {
            IPerspectivePipeline<Message> pipeline = new PerspectivePipeline<Message>();
            Debug.WriteLine(_mailMessage.Object.Tags.Count);
            pipeline.Plugins.Add(new TagSpamPlugin());
            pipeline.Process(_mailMessage.Object);
            foreach (var item in _mailMessage.Object.Tags)
            {
                Debug.WriteLine(item);
            }
            Assert.That(_mailMessage.Object.Tags.Count, Is.EqualTo(1));
            Assert.That(_mailMessage.Object.Tags[0], Is.EqualTo(SystemTags.Spam));
        }
    }
}
